﻿using SmallTool.BaseFile;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SmallTool.frm
{
    public partial class frm_createFileSavePath : Form
    {
        public frm_createFileSavePath()
        {
            InitializeComponent();
        }

        private void btn_browse_Click(object sender, EventArgs e)
        {
            string savePath = txt_path.Text.Trim();
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (!string.IsNullOrWhiteSpace(savePath))
            {
                fbd.SelectedPath = savePath;
            }
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txt_path.Text = fbd.SelectedPath;
            }
        }

        private void btn_save_Click(object sender, EventArgs e)
        {
            string _path = txt_path.Text.Trim();
            if (string.IsNullOrWhiteSpace(_path))
            {
                MessageBox.Show("请选择正确的保存路径");
                return;
            }
            try
            {
                BaseCS.instance.UpdateSaveCreateFilePath(_path);
                MessageBox.Show("保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void frm_createFileSavePath_Load(object sender, EventArgs e)
        {
            txt_path.Text = BaseCS.instance.GetSavePath(1);
            txt_bcPath.Text = BaseCS.instance.GetSavePath(2);
        }

        private void btn_soft_Click(object sender, EventArgs e)
        {
            string saveSoftPath = txt_bcPath.Text.Trim();
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "(*.exe)|*.exe";
            if (!string.IsNullOrWhiteSpace(saveSoftPath))
            {
                ofd.FileName = saveSoftPath;
            }
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txt_bcPath.Text = ofd.FileName;
            }
        }

        private void btn_save_Click_1(object sender, EventArgs e)
        {
            string path = txt_path.Text.Trim();
            if (string.IsNullOrWhiteSpace(path))
            {
                MessageBox.Show("请选择正确的保存路径");
                return;
            }
            BaseCS.instance.UpdateSaveCreateFilePath(path);
            MessageBox.Show("保存成功");
        }

        private void btn_softSave_Click(object sender, EventArgs e)
        {
            string path = txt_bcPath.Text.Trim();
            if (string.IsNullOrWhiteSpace(path))
            {
                MessageBox.Show("请选择正确的对比软件路径");
                return;
            }
            BaseCS.instance.UpdateSaveBCSoftPath(path);
            MessageBox.Show("保存成功");
        }

        private void btn_browse_Click_1(object sender, EventArgs e)
        {

        }
    }
}
